<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pivot Chart Data</title>
</head>

<body>
<%
measure=request.Form("measure")
MeasureObj=request.Form("measureObj")
eachObj=request.Form("eachObj")
groupedbyObj=request.Form("groupedbyObj")
tableObj=request.Form("tableObj")
filterStr=request.Form("filterStr")

if measure="" then no=1
if MeasureObj="" then no=1
if eachObj="" then no=1
if groupedbyObj="" then no=1
if tableObj="" then no=1

if no=1 then response.End()

dim rs,conn
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
filepath=server.MapPath("access\backend\tickets.mdb")
	
conn.open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath
rs.cursorlocation=3 'adUseClient
rs.cursortype=0 'adOpenForwardOnly 
rs.locktype=1 'adLockReadOnly 

mn=measure & "Of" & measureObj
m=measure & "([" & measureObj & "])"
sql="transform " & m & " as " & mn & " select [" & eachObj & "] from [" & tableObj & "] group by [" & eachObj & "] pivot [" & groupedbyObj & "]"
rs.open sql, conn
rs.activeconnection=nothing
%>
<table >
<tr bgcolor="#CCCCCC">
<% for each f in rs.fields %>
<td>&nbsp;<%= f.name %>&nbsp;</td>
<% next %>
</tr>

<% do until rs.eof %>
	<tr> 
	<% cnt=0
	for each f in rs.fields 
		cnt=cnt+1
		if cnt=1 then color="#cccccc" else color="#00ffcc"%>
		<td bgcolor="<%= color %>">&nbsp;<%= f.value %>&nbsp;</td>
	<% next 
	rs.movenext %>
	</tr> 
<% loop %>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>	
	
</body>
</html>
